Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support for conditional stores #2553

Merged
merged 13 commits into from
Sep 13, 2023
Merged

fix: support for conditional stores #2553

merged 13 commits into from
Sep 13, 2023

Conversation

guipublic
Copy link
Contributor

Description

Problem*

Resolves #2493

Summary*

Array Set with side-effect context are replaced by predicate*value+(1-predicate)array read
The index of array operation is also replaced by predicate
index.

This strategy does not work with empty slice since we would access index 0 and that would still fail with an empty slice, but I believe this case is degenerate enough to not support it.

Documentation

  • This PR requires documentation updates when merged.

    • I will submit a noir-lang/docs PR.
    • I will request for and support Dev Rel's help in documenting this PR.

Additional Context

The PR requires ACVM PR 524 for the CI tests to pass.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@vezenovm
Copy link
Contributor

vezenovm commented Sep 5, 2023

This looks to be failing with the same bug I have here (#2446). I'm working on a fix as I think I may know the issue.

@vezenovm
Copy link
Contributor

vezenovm commented Sep 5, 2023

The failing test should pass now if you pull master.

Copy link
Contributor

@vezenovm vezenovm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a test like below to array_dynamic where idx is greater than the length of x?

fn regression_mem_op_predicate(mut x: [u32; 5], idx: Field) {
  // We should not hit out of bounds here as we have a predicate
  // that should not be hit
  if idx as u32 < 3 {    
    x[idx] = 10;
  }
  assert(x[4] == 111);
}

@kevaundray kevaundray requested a review from vezenovm September 7, 2023 11:06
Copy link
Contributor

@vezenovm vezenovm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some comments suggestions mainly, but none are blocking for getting this out

crates/noirc_evaluator/src/ssa/acir_gen/mod.rs Outdated Show resolved Hide resolved
crates/noirc_evaluator/src/ssa/acir_gen/mod.rs Outdated Show resolved Hide resolved
crates/noirc_evaluator/src/ssa/acir_gen/mod.rs Outdated Show resolved Hide resolved
crates/noirc_evaluator/src/ssa/acir_gen/mod.rs Outdated Show resolved Hide resolved
crates/noirc_evaluator/src/ssa/acir_gen/mod.rs Outdated Show resolved Hide resolved
@jfecher
Copy link
Contributor

jfecher commented Sep 7, 2023

LGTM. We can merge once merge conflicts are fixed

vezenovm
vezenovm previously approved these changes Sep 13, 2023
compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs Outdated Show resolved Hide resolved
compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs Outdated Show resolved Hide resolved
@kevaundray kevaundray added this pull request to the merge queue Sep 13, 2023
Merged via the queue into master with commit 6e6d952 Sep 13, 2023
15 checks passed
@kevaundray kevaundray deleted the gd/issue_2493 branch September 13, 2023 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Encode MemoryOp predicates in circuit
4 participants